package com.zenchn.dynamic;

import static com.zenchn.dynamic.TSysOauthCodeDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.zenchn.model.TSysOauthCode;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface TSysOauthCodeDynamicMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_code")
    BasicColumn[] selectList = BasicColumn.columnList(authCodeId, clientId, accountId, expiredTime, authCode, applyTime, redirectUri);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_code")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_code")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_code")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<TSysOauthCode> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_code")
    @InsertProvider(type=SqlProviderAdapter.class, method="insertMultiple")
    int insertMultiple(MultiRowInsertStatementProvider<TSysOauthCode> multipleInsertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_code")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("TSysOauthCodeResult")
    Optional<TSysOauthCode> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_code")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="TSysOauthCodeResult", value = {
        @Result(column="auth_code_id", property="authCodeId", jdbcType=JdbcType.CHAR, id=true),
        @Result(column="client_id", property="clientId", jdbcType=JdbcType.CHAR),
        @Result(column="account_id", property="accountId", jdbcType=JdbcType.CHAR),
        @Result(column="expired_time", property="expiredTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="auth_code", property="authCode", jdbcType=JdbcType.VARCHAR),
        @Result(column="apply_time", property="applyTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="redirect_uri", property="redirectUri", jdbcType=JdbcType.VARCHAR)
    })
    List<TSysOauthCode> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_code")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_code")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, TSysOauthCode, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_code")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, TSysOauthCode, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_code")
    default int deleteByPrimaryKey(String authCodeId_) {
        return delete(c -> 
            c.where(authCodeId, isEqualTo(authCodeId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_code")
    default int insert(TSysOauthCode record) {
        return MyBatis3Utils.insert(this::insert, record, TSysOauthCode, c ->
            c.map(authCodeId).toProperty("authCodeId")
            .map(clientId).toProperty("clientId")
            .map(accountId).toProperty("accountId")
            .map(expiredTime).toProperty("expiredTime")
            .map(authCode).toProperty("authCode")
            .map(applyTime).toProperty("applyTime")
            .map(redirectUri).toProperty("redirectUri")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_code")
    default int insertMultiple(Collection<TSysOauthCode> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, TSysOauthCode, c ->
            c.map(authCodeId).toProperty("authCodeId")
            .map(clientId).toProperty("clientId")
            .map(accountId).toProperty("accountId")
            .map(expiredTime).toProperty("expiredTime")
            .map(authCode).toProperty("authCode")
            .map(applyTime).toProperty("applyTime")
            .map(redirectUri).toProperty("redirectUri")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_code")
    default int insertSelective(TSysOauthCode record) {
        return MyBatis3Utils.insert(this::insert, record, TSysOauthCode, c ->
            c.map(authCodeId).toPropertyWhenPresent("authCodeId", record::getAuthCodeId)
            .map(clientId).toPropertyWhenPresent("clientId", record::getClientId)
            .map(accountId).toPropertyWhenPresent("accountId", record::getAccountId)
            .map(expiredTime).toPropertyWhenPresent("expiredTime", record::getExpiredTime)
            .map(authCode).toPropertyWhenPresent("authCode", record::getAuthCode)
            .map(applyTime).toPropertyWhenPresent("applyTime", record::getApplyTime)
            .map(redirectUri).toPropertyWhenPresent("redirectUri", record::getRedirectUri)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_code")
    default Optional<TSysOauthCode> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, TSysOauthCode, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_code")
    default List<TSysOauthCode> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, TSysOauthCode, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_code")
    default List<TSysOauthCode> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, TSysOauthCode, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_code")
    default Optional<TSysOauthCode> selectByPrimaryKey(String authCodeId_) {
        return selectOne(c ->
            c.where(authCodeId, isEqualTo(authCodeId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_code")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, TSysOauthCode, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_code")
    static UpdateDSL<UpdateModel> updateAllColumns(TSysOauthCode record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(authCodeId).equalTo(record::getAuthCodeId)
                .set(clientId).equalTo(record::getClientId)
                .set(accountId).equalTo(record::getAccountId)
                .set(expiredTime).equalTo(record::getExpiredTime)
                .set(authCode).equalTo(record::getAuthCode)
                .set(applyTime).equalTo(record::getApplyTime)
                .set(redirectUri).equalTo(record::getRedirectUri);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_code")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(TSysOauthCode record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(authCodeId).equalToWhenPresent(record::getAuthCodeId)
                .set(clientId).equalToWhenPresent(record::getClientId)
                .set(accountId).equalToWhenPresent(record::getAccountId)
                .set(expiredTime).equalToWhenPresent(record::getExpiredTime)
                .set(authCode).equalToWhenPresent(record::getAuthCode)
                .set(applyTime).equalToWhenPresent(record::getApplyTime)
                .set(redirectUri).equalToWhenPresent(record::getRedirectUri);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_code")
    default int updateByPrimaryKey(TSysOauthCode record) {
        return update(c ->
            c.set(clientId).equalTo(record::getClientId)
            .set(accountId).equalTo(record::getAccountId)
            .set(expiredTime).equalTo(record::getExpiredTime)
            .set(authCode).equalTo(record::getAuthCode)
            .set(applyTime).equalTo(record::getApplyTime)
            .set(redirectUri).equalTo(record::getRedirectUri)
            .where(authCodeId, isEqualTo(record::getAuthCodeId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_code")
    default int updateByPrimaryKeySelective(TSysOauthCode record) {
        return update(c ->
            c.set(clientId).equalToWhenPresent(record::getClientId)
            .set(accountId).equalToWhenPresent(record::getAccountId)
            .set(expiredTime).equalToWhenPresent(record::getExpiredTime)
            .set(authCode).equalToWhenPresent(record::getAuthCode)
            .set(applyTime).equalToWhenPresent(record::getApplyTime)
            .set(redirectUri).equalToWhenPresent(record::getRedirectUri)
            .where(authCodeId, isEqualTo(record::getAuthCodeId))
        );
    }
}